package com.cd.javacxy.common.listener;

import com.cd.javacxy.common.utils.CategoryCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 初始化分类数据
 *
 * @author cookie
 */
@Component
public class CxyContextLoaderListener implements CommandLineRunner {

    private CategoryCache categoryCache;

    @Autowired
    public void setCategoryCache(CategoryCache categoryCache) {
        this.categoryCache = categoryCache;
    }

    @Override
    public void run(String... args) {
        categoryCache.refreshCategoryCache();
    }
}